Skip to content

London | 26-ITP-Sep | Diana Ausiejute | Sprint 2 | Coursework - #1546

Open
ausiejute wants to merge 13 commits into
CodeYourFuture:mainfrom
ausiejute:Sprint-2
Open

ausiejute wants to merge 13 commits into
CodeYourFuture:mainfrom
ausiejute:Sprint-2

Conversation

@ausiejute

@ausiejute ausiejute commented Nov 18, 2026 •

Copy link
Copy Markdown
  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Task code

CYF-1083

Changelist

  1. Completed all mandatory exercises of this sprint.
  2. Fixed 'Contains' error-handling tests

@ausiejute ausiejute added 📅 Sprint 2 Assigned during Sprint 2 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Nov 18, 2026
Comment on lines +55 to +75
test("should throw an error when passed a string", () => {
expect(() =>
contains("sun", "a").toThrow(new Error("contains requires an object"))
);
});

test("should throw an error when passed a number", () => {
expect(() =>
contains(9, "a").toThrow(new Error("contains requires an object"))
);
});

test("should throw an error when passed a null", () => {
expect(() =>
contains("sun", null).toThrow(new Error("contains requires an object"))
);
});

test("should throw an error when passed no argument", () => {
expect(() => contains().toThrow(new Error("contains requires an object")));
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The string, number, null, and missing-argument cases place .toThrow(...) inside the callback, so Jest never receives a toThrow assertion. The null case also passes a string as the object and null as the key.

To "like" or "dislike" this comment, please follow this link

@cyf-ai-code-reviewer cyf-ai-code-reviewer Bot added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Nov 18, 2026
@cyf-ai-code-reviewer

Copy link
Copy Markdown

The CYF AI review has left comments. It will only review a PR one time. When you have addressed these comments, please request review again and a volunteer will take a look.

@ausiejute ausiejute added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 18, 2026
@tee4tao tee4tao added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Reviewed Volunteer to add when completing a review with trainee action still to take. labels Nov 19, 2026
Comment on lines +23 to +24
const decodeKey = decodeURIComponent(key.replace(/\+/g, " "));
const decodeValue = decodeURIComponent(value.replace(/\+/g, " "));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The regex works fine here. Can you think of something else that would be more readable for a reader who doesn’t want to decode the \+ and the g flag? Have a look at the string methods available on String.prototype and consider whether one of them would do the same job.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could also use the replaceAll. like so:
const decodeKey = decodeURIComponent(key.replaceAll("+", " "));
const decodeValue = decodeURIComponent(value.replaceAll("+", " "));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That’s correct, well done! replaceAll("+", " ") is easier to read than the regex. Nice that you applied it to both lines.

@tee4tao tee4tao added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Nov 19, 2026
@ausiejute
ausiejute requested a review from tee4tao November 19, 2026 13:55
@tee4tao tee4tao added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed. 📅 Sprint 2 Assigned during Sprint 2 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants